package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.utils.DateUtil;
import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter@Setter
public class TravelCommend extends BaseDomain{
    public static final int  WEEK_COMMEND=1;
    public static final int  MONTH_COMMEND=2;
    public static final int  STRATEGY_COMMEND=3;

    private Travel travel;

    private String title;

    private String subTitle;

    private String coverUrl;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone ="GMT+8" )
    private Date schedule;

    private Integer type=WEEK_COMMEND;

    public String getTypeDisPlay(){
        if(type==WEEK_COMMEND){
            return "周推荐";
        }else if(type==MONTH_COMMEND){
            return "月推荐";
        }else if(type==STRATEGY_COMMEND){
            return "攻略推荐";
        }
        return "";
    }

    public String getJson(){
        Map<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("schedule", DateUtil.formatDate(schedule));
        map.put("type",type);
        if(travel!=null){
            map.put("travelId",travel.id);
        }
        return JSONUtils.toJSONString(map);
    }




}